package com.springcloud.apigateway.errormsg;

import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;

import java.util.Map;

/**
 * 自定义错误信息
 * @author AL
 */
@Component
public class OwnerErrorMsg extends DefaultErrorAttributes{

    @Override
    public Map<String, Object> getErrorAttributes(RequestAttributes requestAttributes, boolean includeStackTrace) {
        Map<String, Object> errorAttributes = super.getErrorAttributes(requestAttributes, includeStackTrace);
        errorAttributes.remove("exception");
        errorAttributes.put("myOwnErrorMsg", "bad error");
        return errorAttributes;
    }
}
